package ui;

import javabean.Admin;
import service.imp.ServiceLogicImp;
import tools.Dbutils;
import java.util.Scanner;
import static ui.Show.view;

public class admin {
    public static void main(String[] args) {
        while (true) {
            Scanner scanner = new Scanner(System.in);
            System.out.println("--------------请登录--------------");
            System.out.println("账户：");//aaa
            String user = scanner.next();
            System.out.println("密码：");//123456
            String password = scanner.next();
            String captcha = Dbutils.captcha();
            System.out.println(captcha);
            System.out.println("验证码：");
            String next = scanner.next();
            ServiceLogicImp serviceLogicImp = new ServiceLogicImp();
            Admin admin = serviceLogicImp.adminService(user,password);
            if(!captcha.equals(next)){
                System.out.println("验证码错误");
                continue;
            }
            if(admin==null){
                System.out.println("用户名或密码错误，请重试");
                continue;
            }else{
                view();
                break;
            }
        }
    }
}

